package com.nuanshui.heatedloan.credit.convert;

import com.nuanshui.heatedloan.credit.constant.CreditConverterType;
import com.nuanshui.heatedloan.credit.facade.PayOrderInfoService;
import com.nuanshui.heatedloan.credit.pay.PayType;
import com.nuanshui.heatedloan.credit.pay.TransRequestCode;
import com.nuanshui.heatedloan.middleware.convert.Converter;
import com.nuanshui.heatedloan.middleware.convert.annotation.ConverterAttribute;
import org.springframework.beans.factory.annotation.Autowired;

@ConverterAttribute(typeId = CreditConverterType.PayTypeToTransRequestCode)
public class PayTypeToTransRequestCodeConverter implements Converter {

    @Autowired
    private PayOrderInfoService payOrderInfoService;

    @Override
    public Object convert(Object s, Object param) {

        Integer payType = (Integer) s;

        String transRequestCode = null;

        if (payType == PayType.TYPE_PAY) {
            transRequestCode = TransRequestCode.TRX_CODE_SINGLE_PAY;
        } else if (payType == PayType.TYPE_REPAY) {
            transRequestCode = TransRequestCode.TRX_CODE_REPAY;
        }
        return transRequestCode;
    }
}
